package com.hkts.naturalgas.base.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hkts.naturalgas.base.entity.HktsLastTime;
import com.hkts.naturalgas.base.mapper.HktsLastTimeMapper;
import com.hkts.naturalgas.base.service.IHktsLastTimeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yck
 * @since 2021-06-01
 */
@Service
@Transactional
public class HktsLastTimeServiceImpl extends ServiceImpl<HktsLastTimeMapper, HktsLastTime> implements IHktsLastTimeService {


    @Autowired
    private HktsLastTimeMapper hktsLastTimeMapper;

    @Override
    public IPage<HktsLastTime> selectPage(Page<HktsLastTime> page, HktsLastTime hktsLastTime){
            QueryWrapper<HktsLastTime> query=Wrappers.query();
            QueryWrapper<HktsLastTime> entityWrapper=getEntityWrapper(query, hktsLastTime);
            return hktsLastTimeMapper.selectPage(page,entityWrapper);
    }


    @Override
    public List<HktsLastTime> selectList(HktsLastTime hktsLastTime){
            QueryWrapper<HktsLastTime> query=Wrappers.query();
            QueryWrapper<HktsLastTime> entityWrapper=getEntityWrapper(query, hktsLastTime);
            return hktsLastTimeMapper.selectList(entityWrapper);
    }

    /**
     *  公共查询条件
     * @param entityWrapper
     * @return
     */
    public QueryWrapper<HktsLastTime> getEntityWrapper(QueryWrapper<HktsLastTime> entityWrapper,HktsLastTime hktsLastTime){
            //条件拼接
                   /* if(StringUtils.isNotBlank(hktsLastTime.getLastRowTime())){
                    entityWrapper.like(HktsLastTime.LAST_ROW_TIME,hktsLastTime.getLastRowTime());
                    }*/
            return entityWrapper;
    }
}
